package com.qidianit.mes.pro.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.Process;
import com.qidianit.mes.pro.mapper.ProcessMapper;
import com.qidianit.mes.pro.service.ProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author: wang fei long
 * @Date: 2025/9/17 0017 - 16:10
 */
@Service
public class ProcessServiceImpl implements ProcessService {

    @Autowired
    private ProcessMapper processMapper;

    @Override
    public Result<PageInfo<Process>> selectList(Process process, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Process> processes=processMapper.selectlist(process);
        return Result.success(new PageInfo<>(processes));
    }

    @Override
    public Result<Process> saveProcess(Process process) {
        return processMapper.saveProcess(process)==1?Result.success(process):Result.error("操作失败");
    }

    @Override
    public Result<Process> selectByCode(String processCode) {
        return Result.success(processMapper.selecyByCode(processCode));
    }

    @Override
    public Result<Process> updateById(Process process) {
        return processMapper.updateById(process)==1?Result.success():Result.error("操作失败");
    }

    @Override
    public Result<Process> deleteById(Long id) {
        return processMapper.deleteById(id)==1?Result.success():Result.error("操作失败");
    }

    @Override
    public Result batchDelete(Long[] ids) {
        return processMapper.batchDelete(ids)>0?Result.success():Result.error("操作失败");
    }


}
